/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clases;

import java.awt.Component;
import javax.swing.JButton;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.table.TableCellRenderer;

/**
 * Procesamiento de Botones de la Tabla
 * @author !gaso
 */
public class ButtonRenderer extends JButton implements TableCellRenderer {

        /**
         *
         * @param ed_img Ruta de la Imagen que se mostrara
         * cuando se encuentre en estado Normal (No Clic)
         */
        public ButtonRenderer(String ed_img) {
            setOpaque(true);

            //Agregar Imagen al Boton en estado Normal
            setIcon(new javax.swing.ImageIcon(getClass().getResource(ed_img)));
            
            //Agregar ToolTip al Boton
            //setToolTipText("TOOL TIP");
            
            //Definir Margen
            setMargin(new java.awt.Insets(2, 2, 2, 2));
            
            setSize(79, 25);
        }

        public Component getTableCellRendererComponent(JTable table, Object value,
                boolean isSelected, boolean hasFocus, int row, int column) {
            if (isSelected) {
                setForeground(table.getSelectionForeground());
                setBackground(table.getSelectionBackground());
                
            } else {
                setForeground(table.getForeground());
                setBackground(UIManager.getColor("Button.background"));
            }
            setText((value == null) ? "" : value.toString());
            return this;
        }
    }
